"""
客户页面类
"""
from ..base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

class CustomerPage(BasePage):
    #数据
    url="/crm/index.php?m=customer"
    #定位器
    customer_locator = (By.LINK_TEXT, "客户")
    btn_khgj_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > div > div > button")
    khdc_locator = (By.ID, "excelExport")
    add_customer_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(1) > div > a")
    select1_locator = (By.CSS_SELECTOR, "#field")
    select2_locator = (By.CSS_SELECTOR, "#condition")
    input_locator = (By.CSS_SELECTOR, "#search")
    search_locator = (By.CSS_SELECTOR, "#dosearch")
    customer_gh_locator = (By.CSS_SELECTOR, "body > div.container > div.page-header > ul > li:nth-child(4) > a")
    edit_customer_locator = (By.LINK_TEXT, "编辑")
    tips_edit_customer_locator = (By.XPATH, "/html/body/div[5]/div[2]")
    tips_add_success_locator=(By.CSS_SELECTOR,"body > div.container > div.alert.alert-success")
    tips_customer_locator = (By.LINK_TEXT, "客户")
    tips_search_customer_locator = (By.CSS_SELECTOR, "# form1 > table > tbody > tr > td:nth-child(3) > a > span")

    #方法
    def find_customer(self):  #进入到站内信页面
        self.click(self.customer_locator)
    def customer_gj(self): #点击客户工具
        self.click(self.btn_khgj_locator)
    def customer_dc(self): #点击客户导出
        self.click(self.khdc_locator)
    def add_customer(self):
        self.click(self.add_customer_locator)
    def select1(self,select1):
        s1=self.find_element(self.select1_locator)
        s1_obj=Select(s1)
        s1_obj.select_by_visible_text(select1)
    def select2(self,select2):
        s2=self.find_element(self.select2_locator)
        s2_obj=Select(s2)
        s2_obj.select_by_visible_text(select2)
    def input(self,name):
        self.send_keys(self.input_locator,name)
    def search(self):
        self.click(self.search_locator)
    def customer_gh(self):
        self.click(self.customer_gh_locator)
    def edit_customer(self):
        self.click(self.edit_customer_locator)
    def tips_edit_customer(self):  #编辑断言
        return self.find_element(self.tips_edit_customer_locator).text
    def tips_add_success(self):  #成功断言
        return self.find_element(self.tips_add_success_locator).text
    def tips_custome(self):  #客户断言
        return self.find_element(self.tips_customer_locator).text
    def tips_search_customer(self):  #客户断言
        return self.find_element(self.tips_search_customer_locator).text